#include <iostream>
#include <algorithm>

using namespace std;

int solution1(int n, int m, int curr_seg) {
  if (curr_seg > n) {
    return 0;
  }
  else if (m >= curr_seg) {
    return solution1(n, m, curr_seg * 2) + 1;
  }
  else {
    return solution1(n, m, curr_seg + m) + 1;
  }
}

int solution2(int n, int m) {
  int count = 0;
  int curr = 1;

  while (n > curr) {
    curr += min(curr, m);
    count += 1;
  } 

  return count;
}

int main(int argc, char const *argv[])
{
  /* code */
  cout << solution1(8, 3, 1) << endl;
  cout << solution2(8, 3) << endl;
  return 0;
}
